package game.Engine.Entity;

import java.awt.Point;

import game.display.Animation;
import game.display.Images;

public class PowerUp extends Entity {
	private Type type;
	
	public enum Type{
	   /**
	    * the enumeration representing the types of powerups
	    */
		AIR,
		WATER,
		FIRE,
		EARTH,
		LIGHTNING,
		DOUBLEJUMPPOWER,
		HEALTH
	}
	/**
	 * Creates a new Powerup at a specific point
	 * @param p the powerup to be created
	 * @param i the type of the powerup
	 */ 
	public PowerUp(Point p, int i){
		super((double)p.getX(), (double)p.getY(), getPowerUp(i));
		this.state = State.NORMAL;
		setType(i);
	}
	
	private void setType(int i){
		if(i == 0) type = Type.EARTH;
		else if(i == 1) type = Type.FIRE;
		else if(i == 2) type = Type.LIGHTNING;
		else if(i == 3) type = Type.WATER;
		else if(i == 4) type = Type.HEALTH; 
		else type = Type.DOUBLEJUMPPOWER;
	}
	
	@Override
	public void die() {
	   this.state = State.DEAD;
	}
	private static Animation getPowerUp(int rand) {
		if(rand == 0) return Images.GREENPOWERUP.image();
		else if(rand == 1) return Images.FIREPOWERUP.image();
		else if(rand == 2) return Images.LIGHTNINGPOWERUP.image();
		else if(rand == 3) return Images.WATERPOWERUP.image();
		else if(rand == 4) return Images.HEALTH.image();
		else return Images.DOUBLEJUMPPOWERUP.image();
	}
	
	@Override 
	public void update(long timeElapsed) {
		super.update(timeElapsed);
	}
	@Override
	public void handleCollision(Entity e) {
	   die();
	}
	/**
	 * returns the type of the powerup
	 * @return the type of the powerup
	 */
	public Type getType(){
		return type;
	}
}
